package com.tgu.home_action.dao;

import com.tgu.home_action.pojo.Dynamic;
import com.tgu.home_action.pojo.Place;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DynamicMapper {
    @Insert("insert into dynamic (case_id,volunteer_id,family_id,action_id,name,avatar_url)" +
            "values(#{caseId},#{volunteerId},#{familyId},#{actionId},#{name},#{avatarUrl})")
    void insertDynamic(Dynamic dynamic);

    /**
     * 查询动态数量
     */
    @Select("select count(1) from dynamic")
    int getSum();

    /**
     * 查询动态
     */
    List<Dynamic> getDynamic(Dynamic dynamic);

    /**
     * 通过案件ID查询动态
     */
    @Select("select * from dynamic where case_id=#{caseId} order by time desc")
    List<Dynamic> getDynamicByCaseId(Integer caseId);

    /**
     * 通过位置查询案件动态
     */
    List<Dynamic> getDynamicByPlace(Place place);
}
